<?php
header("Content-Type:text/html;charset=UTF-8");
include("./API.php");
include("../config.php");
tongji("qcy");
$mathematics=$_GET["quantity"]?:'9';//需要查询的人数(最多40人一页)
$b=$_GET["n"]?:'1';//需要获取的页数
$hh=$_GET["hh"]?:"\n";//换行符号(默认\n)
$end=$mathematics*$b;
$url="https://qun.qq.com/cgi-bin/qun_mgr/search_group_members";
$data='gc='.$_GET["group"].'&st='.($end-$mathematics).'&end='.$end.'&sort=0&bkn='.getGTK($_GET["skey"]).'';
$return_content=http_post_data($url, $data);
$result=preg_match_all("/uin\":(.*?),\"role\":(.*?),\"g\":(.*?),\"join_time\":(.*?),\"last_speak_time\":(.*?),\"lv\":{\"point\":(.*?),\"level\":(.*?)},\"card\":\"(.*?)\",\"tags\":\"(.*?)\",\"flag\":(.*?),\"nick\":\"(.*?)\"/",$return_content,$arr);
$pst= json_decode($return_content);
$hw_id=$pst->ec;
if($hw_id==0){
if($result!="0"){
function escape($str) {
  return str_replace('\\', '%', substr(json_encode($str), 1, -1));
}
function unescape($str) {
  return json_decode('"'.str_replace('%', '\\', $str).'"');
}
echo "".$web["ming"]."API♧QQ群成员列表".$hh."";
echo "━━━━━━━━━".$hh."";
for ($i=0; $i <$result ; $i++){
$aa=$arr[11][$i];
$str=str_replace("&nbsp;"," ","".$aa."");
$cc=$arr[1][$i];
echo ($i+1)."：".unescape($str)."－".$cc."".$hh."";
}
echo "每页".($mathematics+1)."人，当前第".$b."页".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}}else
if($hw_id==1){
echo "".$web["ming"]."API♧QQ群成员列表".$hh."";
echo "━━━━━━━━━".$hh."";
echo "参数错误".$hh."";
echo "━━━━━━━━━".$hh."";
echo "Tips:".$web["ming"]."API技术支持";
}
function getGTK($skey){
$len = strlen($skey);
$hash = 5381;
for ($i = 0; $i < $len; $i++) {
$hash += ($hash << 5 & 2147483647) + ord($skey[$i]) & 2147483647;
$hash &= 2147483647;
}
return $hash & 2147483647;
}

function http_post_data($url, $data_string) {
	$ch = curl_init();
	curl_setopt($ch, CURLOPT_POST, 1);
	curl_setopt($ch, CURLOPT_URL, $url);
	curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
	curl_setopt($ch, CURLOPT_HTTPHEADER, array(
	"Content-Type: application/x-www-form-urlencoded",
		"Content-Length: " . strlen($data_string),
		"Cookie: p_uin=o".$_GET["qq"]."; uin=o".$_GET["qq"]."; skey=".$_GET["skey"]."; p_skey=".$_GET["pskey"]
		));
	ob_start();
	curl_exec($ch);
	$return_content = ob_get_contents();
	ob_end_clean();
	return $return_content;
}
?>